<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>emplist</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css"/>
    <script src="${pageContext.request.contextPath}/jQuery/jquery-3.4.1.min.js"></script>
</head>
<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader">
                <p>
                    2009/11/20
                    <br/>
                </p>
            </div>
            <div id="topheader">
                <h1 id="title">
                    <a href="#">main</a>
                </h1>
            </div>
            <div id="navigation">
            </div>
        </div>
        <div id="content">
            <p id="whereami">
            </p>
            <h1>
                Welcome!
            </h1>
            <table class="table">
                <tr class="table_header">
                    <td>
                        ID
                    </td>
                    <td>
                        Name
                    </td>
                    <td>
                        Salary
                    </td>
                    <td>
                        Age
                    </td>
                    <td>
                        Operation
                    </td>
                </tr>
                <c:forEach items="${emps}" var="emp">
                    <tr class="row1">
                        <td>
                                ${emp.id}
                        </td>
                        <td>
                                ${emp.name}
                        </td>
                        <td>
                                ${emp.salary}
                        </td>
                        <td>
                                ${emp.age}
                        </td>
                        <td>
                            <a href="${pageContext.request.contextPath}/manager/safe/deleteEmp?id=${emp.id}">delete
                                emp</a>&nbsp;
                            <a href="${pageContext.request.contextPath}/manager/safe/showEmp?id=${emp.id}">update
                                emp</a>
                        </td>
                    </tr>

                </c:forEach>
                <tr>
                    <td>第${page.pageIndex}/${page.totalPages}页</td>

                    <td>共${page.totalCounts}条</td>

                    <td>
                        <a href="${pageContext.request.contextPath}/manager/safe/showAllEmp?pageIndex=1">首页</a>

                        <c:if test="${page.pageIndex == 1}">
                            <a>上一页</a>
                        </c:if>
                        <c:if test="${page.pageIndex > 1}">
                            <a href="${pageContext.request.contextPath}/manager/safe/showAllEmp?pageIndex=${page.pageIndex-1}">上一页</a>
                        </c:if>
<%--                        <a id="a1">下一页</a>--%>
                        <c:if test="${page.pageIndex == page.totalPages}">
                            <a>下一页</a>
                        </c:if>
                        <c:if test="${page.pageIndex < page.totalPages}">
                            <a href="${pageContext.request.contextPath}/manager/safe/showAllEmp?pageIndex=${page.pageIndex+1}">下一页</a>
                        </c:if>

                        <a href="${pageContext.request.contextPath}/manager/safe/showAllEmp?pageIndex=${page.totalPages}">尾页</a>
                    </td>
                </tr>

            </table>
            <p>
                <input type="button" class="button" value="Add Employee" onclick="location='${pageContext.request.contextPath}/addEmp.jsp'"/>
            </p>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">
            ABC@126.com
        </div>
    </div>
</div>
<script>
    <%--$(function () {--%>
    <%--  $("#a1").click(function() {--%>
    <%--      var url = "${pageContext.request.contextPath}/manager/safe/showAllEmp1?pageIndex=${page.pageIndex-1}";--%>
    <%--      $.get(url,function(data) {--%>
    <%--          console.log(data);--%>
    <%--          // $("tr.row1").children().remove();--%>
    <%--          // var id = "<td>"+data.id+"</td>";--%>
    <%--          // $("tr.row1").append(id);--%>
    <%--          $("tr.table_header").siblings().remove();--%>
    <%--          var tr1 = "<tr><td>"+data.id+"</td><td>"+data.name+"</td><td>"+data.salary+"</td><td>"+data.age+"</td></tr>";--%>
    <%--          $("table").append(tr1);--%>
    <%--      });--%>
    <%--  });--%>
    <%--});--%>
</script>
</body>
</html>
